﻿using System;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
using HelixToolkit.Wpf;

namespace GameBoard
{
    internal class ArrowVisual : ArrowVisual3D, IVisual, IFade
    {
        private Duration _showDuration;
        bool _belongsToMoveablePicture = false;
        public bool BelongsToMoveablePicture
        {
            get { return _belongsToMoveablePicture; }
        }
        public void PopulateVisualData(BaseVisualData theData)
        {
            _belongsToMoveablePicture = theData.BelongsToMoveablePicture;
            FactoryID = theData.FactoryID;
            
            var arrowData = theData as ArrowVisualData;
            Point1 = arrowData.Origin;
            Diameter = arrowData.Diameter;
            Material = arrowData.Material;
            Origin = arrowData.Origin;
            Point2 = arrowData.Point2;
            _showDuration = arrowData.ShowDuration;
            FadeOut();
        }

        public ModelVisual3D VisualElement
        {
            get { return this; }
        }
        public Guid FactoryID { get; set; }
        

        public void FadeOut()
        {
            var moveAnimationPic = new DoubleAnimation(1, .1, _showDuration);
            AnimationClock clock1 = moveAnimationPic.CreateClock();
            ApplyAnimationClock(ArrowVisual3D.DiameterProperty, clock1);
        }



    
    }
}